package com.tedu.parkinglot.carPort.controller;

import com.tedu.parkinglot.base.response.JsonResult;
import com.tedu.parkinglot.carPort.pojo.dto.CarportQuery;
import com.tedu.parkinglot.carPort.pojo.dto.CarportSaveParam;
import com.tedu.parkinglot.carPort.pojo.vo.CarportVO;
import com.tedu.parkinglot.carPort.service.CarportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;
import java.util.List;

@Slf4j
@RestController
@RequestMapping("/carport")
public class CarportController {

    @Autowired
    private CarportService carportService;

    @GetMapping("select")
    public JsonResult select(CarportQuery carportQuery) {
        List<CarportVO> list = carportService.select(carportQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("save")
    public JsonResult save(CarportSaveParam carportSaveParam) {
        log.debug("新增车位：carportSaveParam{}", carportSaveParam);
        carportService.save(carportSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    public JsonResult delete(@PathVariable Long id) {
        log.debug("删除车位：id{}", id);
        carportService.delete(id);
        return JsonResult.ok();
    }
}
